<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">
    $(function () {
        init();
    });
    var dateModule = (function () {
        /*初始化时间查询*/
        var initDate = function () {
            $("input[name='latestUserTimeStart']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});
            });
            $("input[name='latestUserTimeEnd']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});
            });
            //$("input[name='payTime_end']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
        };
        var module = {
            init: function () {
                initDate();
            }
        };
        return module;
    })();
    function init() {
        var datagrid = $("#mallShopCardUseListtb");
        //datagrid.find("div[name='searchColums']").append($("#tempSearchColums div[name='searchColums']").html());
        var shuntListForm = datagrid.find("div[name='searchColums']").find("form#mallShopCardUseListForm");
        shuntListForm.html("");
        shuntListForm.append($("#searchColumsDiv").html());
        shuntListForm.css('display', 'block');
        $("#searchColumsDiv").html('');
        dateModule.init();
        getStatic();
    }

    //获取统计信息
    function getStatic() {
        var queryParams = {};
        $('#mallShopCardUseListtb').find('*').each(function () {
            queryParams[$(this).attr('name')] = $(this).val();
        });
        $.ajax({
            type: "POST",
            url: "mallShopCardUseController.do?getStaticInfo",
            dataType: "json",
            data: queryParams,
            success: function (data) {
                $("#total").html(data.total);
                $("#normalUse").html(data.normalUse);
                $("#overThrityDay").html(data.overThrityDay);
                $("#overThreeDay").html(data.overThreeDay);
                $("#lossed").html(data.lossed);
            }
        });
    }
    //根据数据状态展示不同颜色
    function changeColor(index, row) {
        if (row.state == 3) {
            //已挂失的卡背景标示为绿色，使用状态记录为已挂失
            return 'background-color:#94d399;';
        } else if (row.orderCreateTime==""&&row.lastUseDay > 3) {
            //新录入卡从录入时间起，超过3天未投入使用（包括油卡申领、油卡商城充值，油卡运单预付），则视为异常，背景标示为蓝色
            return 'background-color:#82dbd3;';
        } else if (row.orderCreateTime!=""&&row.lastUseDay > 30) {
            //有使用记录的卡，距上次使用时间超过30天视为异常，背景标示为红色
            return 'background-color:#f3c0c0;';
        }
    }
</script>
<div id="searchColumsDiv" style="display: none">
 <div style="height:30px;background-color:#e9e9e9;padding-left: 10px;margin-bottom: 10px;">
                <span style="vertical-align:middle;">
                     使用记录（共<span id="total"></span>张，正常使用<span id="normalUse"></span>张，超过30天未使用<span id="overThrityDay"></span>张，超过3天未使用<span id="overThreeDay"></span>张，已挂失<span id="lossed"></span>张）
                    </span>
 </div>
 <div name="searchColums"><input id="_sqlbuilder" name="sqlbuilder" type="hidden">
  <link rel="stylesheet" href="plug-in/Validform/css/style.css" type="text/css">
  <link rel="stylesheet" href="plug-in/Validform/css/tablefrom.css" type="text/css">
  <span style="display:-moz-inline-box;display:inline-block;"><span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="油卡号">油卡号：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                        name="cardNo" class="inuptxt" style="width: 150px">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;">
   <span
           style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
           title="运单号">运单号：</span>
   <input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
          name="waybillNumber" class="inuptxt" style="width: 150px">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;">
   <span
           style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
           title="订单号">订单号：</span>
   <input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
          name="orderNo" class="inuptxt" style="width: 150px">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;"><span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 100px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="录入/使用时间">录入/使用时间：</span>
   <input onkeypress="EnterPressCus(event)" onkeydown="EnterPressCus()" type="text" name="latestUserTimeStart" class="Wdate" style="width: 135px">
   至
   <input onkeypress="EnterPressCus(event)" onkeydown="EnterPressCus()" type="text" name="latestUserTimeEnd" class="Wdate" style="width: 135px">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;">
   <span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="关联项目组">关联项目组：</span>
      <input name="projectId" type="hidden" id="projectId">
      <input type="text" name="projectName" id="projectName" class="inuptxt" style="width: 100px" readonly="readonly" onclick="openProjectSelect()">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;">
   <span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="关联人员">关联人员：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                          name="projectUserName" class="inuptxt" style="width: 100px">
  </span>
  <span
          style="display:-moz-inline-box;display:inline-block;">
   <span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="使用类型">使用类型：</span>
    <select name="useType" style="width: 100px">
     <option value="">请选择</option>
     <option value="0">新卡发放</option>
     <option value="1">运费支付</option>
     <option value="2">商城充值</option>
     <option value="3">油卡申领</option>
    </select>
  </span>
     <span
             style="display:-moz-inline-box;display:inline-block;">
   <span
           style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
           title="使用状态">使用状态：</span>
    <select name="useStatus" style="width: 100px">
     <option value="">请选择</option>
     <option value="0">正常使用</option>
     <option value="1">旧卡未使用</option>
     <option value="2">新卡未使用</option>
     <option value="3">已挂失</option>
    </select>
  </span>
 </div>
</div>

<div class="easyui-layout" fit="true">
 <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="mallShopCardUseList" title="油卡使用管理" actionUrl="mallShopCardUseController.do?datagrid" idField="id" fit="true" queryMode="group" onLoadSuccess="getStatic" fitColumns="true" rowStyler="changeColor">
   <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
   <t:dgCol title="最近使用时间间隔" field="lastUseDay" hidden="true"></t:dgCol>
   <t:dgCol title="最近使用时间" field="orderCreateTime" hidden="true"></t:dgCol>
   <t:dgCol title="油卡号" field="cardNo"  query="true"></t:dgCol>
   <t:dgCol title="录入/使用时间" field="latestUserTime" query="true"  formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
   <t:dgCol title="买家" field="buyer" ></t:dgCol>
   <t:dgCol title="订单号" field="orderNo" query="true"></t:dgCol>
   <t:dgCol title="司机" field="driver"></t:dgCol>
   <t:dgCol title="司机电话" field="mobile"></t:dgCol>
   <t:dgCol title="使用车辆" field="vehicleNo"></t:dgCol>
   <t:dgCol title="运单号" field="waybillNumber" query="true"></t:dgCol>
   <t:dgCol title="货主" field="consignor"></t:dgCol>
   <t:dgCol title="金额（元）" field="productMoney"></t:dgCol>
   <t:dgCol title="关联项目组" field="projectName"></t:dgCol>
   <t:dgCol title="关联人员" field="projectUserName"  query="true"></t:dgCol>
   <t:dgCol title="使用类型" field="useType"  query="true"></t:dgCol>
   <t:dgCol title="使用状态" field="useStatus" query="true"></t:dgCol>
   <t:dgCol title="操作" field="opt"></t:dgCol>
   <t:dgFunOpt funname="view(cardNo,useStatus)" title="查看"></t:dgFunOpt>
   <t:dgToolBar title="导出" icon="icon-putout" funname="exportCard"></t:dgToolBar>
  </t:datagrid>
 </div>
</div>
<script type="text/javascript">
    //导出
    function exportCard(){
        JeecgExcelExport("mallShopCardUseController.do?exportCard", "mallShopCardUseList");
    }

    function view(cardno,useStatus) {
        addOneTab("油卡详情","mallProjectController.do?cardInfo&cardno="+cardno);
    }
    function openProjectSelect() {
        //getSelectTaskDetailId("taskDetailId");
        $.dialog.setting.zIndex = 9999;
        $.dialog({
            content: 'url:mallProjectController.do?projects',
            zIndex: 2300,
            title: '选择项目组',
            lock: true,
            width: '400px',
            height: '350px',
            opacity: 0.4,
            button: [
                {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackSearch, focus: true},
                {
                    name: '<t:mutiLang langKey="common.cancel"/>', callback: function () {
                }
                }
            ]
        }).zindex();
    }
    //选择项目中后
    function callbackSearch() {
        var iframe = this.iframe.contentWindow;
        var rowsData = iframe.$('#projectList').datagrid('getSelections');

        if (!rowsData || rowsData.length==0) {
            $("#projectId").val("");
            $("#projectName").val("");
        }
        if (rowsData.length==1) {
            $("#projectId").val(rowsData[0].id);
            $("#projectName").val(rowsData[0].projectname);
        }
    }
</script>